<template>
  <div style="padding: 50px 20px 40px 10px">
    <el-card class="box-card">
      <el-row>
        <el-col :span="8">
          <el-form ref="form" label-width="80px">
            <div class="main">
              <el-form-item label="关键字">
                <el-input v-model="searchEle" placeholder="根据编号搜索" />
              </el-form-item>
            </div>
          </el-form>
        </el-col>
        <el-col :span="16">
          <div class="btnMain">
            <el-button class="btn">清除</el-button>
            <el-button type="primary" class="btn">搜索</el-button>
          </div>
        </el-col>
        <el-alert type="info" :closable="false" class="incoTitle">
          <i class="el-icon-info" style="font-size: 16px"></i>
          数据一共x条
        </el-alert>
      </el-row>
      <!-- 表格 -->
      <div class="formEle">
        <el-table
          :data="tableData"
          style="width: 100%"
          :header-cell-style="{ backgroundColor: '#fafafa' }"
        >
          <el-table-column prop="date" label="编号" width="210" />
          <el-table-column prop="name" label="题型" width="100" />
          <el-table-column prop="address" label="题目编号" width="160">
            <template #default="{ row }">
              <a href="#" class="aLink">{{ row }}</a>
            </template>
          </el-table-column>
          <el-table-column prop="address" label="录入时间" width="170" />
          <el-table-column prop="address" label="答题时间(s)" width="180" />
          <el-table-column prop="address" label="正确率(%)" width="220" />
          <el-table-column prop="address" label="录入人" width="220" />
          <el-table-column label="操作">
            <el-button
              type="danger"
              class="btnEle"
              icon="el-icon-delete"
              circle
              plain
            />
          </el-table-column>
        </el-table>
      </div>

      <!-- 分页 -->
      <div class="block">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage4"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="10"
          background
          layout="prev, pager, next, sizes, jumper"
          :total="50"
        />
      </div>
    </el-card>
  </div>
</template>
<script>
import { getQuestionsRandomsApi } from '@/api/menu'
export default {
  data() {
    return {
      searchEle: '1',
      currentPage4: 1,
      sizeForm: 1,
      // 表格数据数组
      tableData: [
        {
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        },
        {
          date: '2016-05-04',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1517 弄'
        },
        {
          date: '2016-05-01',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1519 弄'
        },
        {
          date: '2016-05-03',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1516 弄'
        }
      ]
    }
  },
  async created() {
    const obj = {
      page: '1',
      pagesize: '10'
    }
    const res = await getQuestionsRandomsApi(obj)
    console.log(res)
  },
  methods: {
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`)
    }
  }
}
</script>
<style scoped lang="scss">
.btnMain {
  margin-left: 85%;
}
.btn {
  width: 60px;
  height: 30px;
  padding: 9px;
  font-size: 13px;
}
/* .el-input__inner */
.main {
  ::v-deep {
    .el-input__inner {
      height: 35px;
      width: 260px;
    }
  }
}
.incoTitle {
  line-height: 20px;
  margin-bottom: 15px;
}
.btnEle {
  width: 35px;
  height: 35px;
  padding: 9px;
}
.block {
  float: right;
  margin: 10px;
}
.aLink {
  color: #0099ffec;
}
</style>
